﻿using ArtMath.Core.Data;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace ArtMath.AuxiliaryTool
{
    /// <summary>
    /// 尺寸设置器
    /// </summary>
    public class SizeSetter : RectangleDragger
    {
        public event Action<RectangleD> CreateObject;
        public SizeSetter(PointD initLocation) : base(initLocation)
        {

        }

        public override void Paint(Graphics gra)
        {
            SmoothingMode bkp = gra.SmoothingMode;
            gra.SmoothingMode = SmoothingMode.HighSpeed;
            Pen P = new Pen(Color.Black, 1)
            {
                DashStyle = DashStyle.Dash,
            };
            RectangleF rect = InitialRectangle.ToStandardRectangle().ToRectangleF();
            gra.DrawRectangle(P, rect.Left, rect.Top, rect.Width, rect.Height);
            gra.SmoothingMode = bkp;
        }
        public override void Complete()
        {
            CreateObject?.Invoke(InitialRectangle);
            base.Complete();
        }
    }
}
